<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <title>个人信息- 千锋新闻</title>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/reset.css',_external=True) }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/animate.css',_external=True) }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/style.css',_external=True) }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/cityLayout.css',_external=True) }}">

    <link rel="stylesheet" type="text/css"
          href="{{ url_for('static',filename='css/lq.datetimepick.css',_external=True) }}"/>


    <script src="{{ url_for('static',filename='js/jquery.min.js',_external=True) }}" type="text/javascript"></script>
    <script src="{{ url_for('static',filename='js/jquery-migrate-1.2.1.min.js',_external=True) }}"
            type="text/javascript"></script>
</head>
<body>
<section class="headerwrap headerwrap2">
    <header>
        <div class="header2 header">
            <div class="top">
                <div class="wp">
                    <div class="fl"><p>服务电话：<b>33333333</b></p></div>
                    <div style="float: right;"><a href="{{ url_for("index.home") }}" style="color: white">回到首页</a></div>
                </div>
            </div>

            <div class="middle">
                <div class="wp">
                    <h1>我的个人中心</h1>
                </div>
            </div>
        </div>
    </header>
</section>


<!--crumbs start-->

<section>
    <div class="wp">
        <ul class="crumbs">
            <li><a href="{{ url_for("index.home") }}">首页</a>></li>
            <li><a href="#">个人中心</a>></li>
            <li>我的收藏</li>
        </ul>
    </div>
</section>

<section>
    <div class="wp list personal_list">
        <div class="left">
            <ul>
                <li><a href="{{ url_for("account.center") }}">个人资料</a></li>
                <li><a href="{{ url_for('account.update') }}">修改密码</a></li>
                <li class="active2"><a href="{{ url_for('account.store') }}">我的收藏</a></li>
            </ul>
        </div>


        <div class="right">
            <div class="personal_des ">
                <div class="head" style="border:1px solid #eaeaea;">
                    <h1>我的收藏&nbsp;&nbsp;&nbsp;<font size="3">收藏数:{{ store_num }}</font></h1>
                </div>
                <div class="inforcon" style="padding: 15px;">
                    <ul>
                        {% for new in news %}
                            <li style="padding: 10px">
                                <a href="{{ url_for('news.details') }}?new={{ new.hash_id }}">{{ new.title }}</a>&nbsp;&nbsp;&nbsp;{{ new.author }}&nbsp;&nbsp;&nbsp;{{ new.create_time }}
                                <button id="cancel" style="float: right;margin-right: 20px">取消收藏</button>
                                <p hidden id="new_id">{{ new.hash_id }}</p>
                            </li>
                        {% endfor %}
                    </ul>
                </div>
            </div>
        </div>


    </div>
</section>


<script>
    //个人中心取消收藏
    $('#cancel').on('click', function () {
        var new_id = $("#new_id").text()
        var csrftoken = $('meta[name=csrf-token]').attr('content')
        $.ajax({
            type: "POST",
            url: "{{ url_for('account.store') }}",
            data: {"new_id": new_id},
            dataType: 'json',
            async: true,
            beforeSend: function (xhr, settings) {
                if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type)) {
                    xhr.setRequestHeader("X-CSRFToken", csrftoken)
                }
            },
            success: function (data) {
                if (data.status == 'fail') {
                    window.location.href = "#";
                } else if (data.status == 'success') {
                    window.location.reload();//刷新当前页面.
                }
            },
        });
    });
</script>
</body>
</html>
